package com.milhouz.bomberrokon.sprite;

import com.stickycoding.Rokon.Rokon;
import com.stickycoding.Rokon.Texture;

/**
 * Bomb sprite
 */
public class BombSprite extends SolidObject {

	private static final int ANIME_BOMB_PLANTED[] = { 1, 2, 3 };
	private static final int ANIM_FRAME_TIME = 200;
	private static final int BOMB_TIME = 3000;

	private int bombId;
	private int bomberId;
	private int bombForce;
	/** Bomb live timer (ms) */
	private long mBombTimer = 0;
	/** Indicates if collisions must be computed between the bomb and the bomber */
	private boolean collisionFlag = false;
	/** the flag is true, when the bomb explosion is trigger before the end */
	private boolean explosionFlag = false;

	public BombSprite(int bombId, int bomberId, int bombForce, float x, float y, Texture bombTextures) {
		super(x, y, bombTextures);
		this.bombId = bombId;
		this.bomberId = bomberId;
		this.bombForce = bombForce;
		super.animateCustom(ANIME_BOMB_PLANTED, ANIM_FRAME_TIME);
		mBombTimer = Rokon.getTime();
	}

	public boolean mustExplose() {
		if ((Rokon.getTime() - mBombTimer) >= BOMB_TIME || explosionFlag) {
			destroySprite();
			return true;
		}
		return false;
	}

	public void destroySprite() {
		this.setVisible(false);
		markForRemoval();
	}

	public int getBombId() {
		return bombId;
	}

	public boolean isCollisionFlag() {
		return collisionFlag;
	}

	public void setCollisionFlag(boolean collide) {
		collisionFlag = collide;
	}

	public int getBomberId() {
		return bomberId;
	}

	public int getBombForce() {
		return bombForce;
	}

	public void setExplosionFlag(boolean explosionFlag) {
		this.explosionFlag = explosionFlag;
	}

}
